<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=9"/>
<meta name="generator" content="Doxygen 1.8.14"/>
<meta name="viewport" content="width=device-width, initial-scale=1"/>
<title>FabGL: MouseOnScreen/MouseOnScreen.ino</title>
<link href="tabs.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="dynsections.js"></script>
<link href="navtree.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="resize.js"></script>
<script type="text/javascript" src="navtreedata.js"></script>
<script type="text/javascript" src="navtree.js"></script>
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:cf05388f2679ee054f2beb29a391d25f4e673ac3&amp;dn=gpl-2.0.txt GPL-v2 */
  $(document).ready(initResizable);
/* @license-end */</script>
<link href="search/search.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="search/searchdata.js"></script>
<script type="text/javascript" src="search/search.js"></script>
<link href="doxygen.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div id="top"><!-- do not remove this div, it is closed by doxygen! -->
<div id="titlearea">
<table cellspacing="0" cellpadding="0">
 <tbody>
 <tr style="height: 56px;">
  <td id="projectalign" style="padding-left: 0.5em;">
   <div id="projectname">FabGL
   </div>
   <div id="projectbrief">ESP32 VGA Controller and Graphics Library</div>
  </td>
 </tr>
 </tbody>
</table>
</div>
<!-- end header part -->
<!-- Generated by Doxygen 1.8.14 -->
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:cf05388f2679ee054f2beb29a391d25f4e673ac3&amp;dn=gpl-2.0.txt GPL-v2 */
var searchBox = new SearchBox("searchBox", "search",false,'Search');
/* @license-end */
</script>
<script type="text/javascript" src="menudata.js"></script>
<script type="text/javascript" src="menu.js"></script>
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:cf05388f2679ee054f2beb29a391d25f4e673ac3&amp;dn=gpl-2.0.txt GPL-v2 */
$(function() {
  initMenu('',true,false,'search.php','Search');
  $(document).ready(function() { init_search(); });
});
/* @license-end */</script>
<div id="main-nav"></div>
</div><!-- top -->
<div id="side-nav" class="ui-resizable side-nav-resizable">
  <div id="nav-tree">
    <div id="nav-tree-contents">
      <div id="nav-sync" class="sync"></div>
    </div>
  </div>
  <div id="splitbar" style="-moz-user-select:none;" 
       class="ui-resizable-handle">
  </div>
</div>
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:cf05388f2679ee054f2beb29a391d25f4e673ac3&amp;dn=gpl-2.0.txt GPL-v2 */
$(document).ready(function(){initNavTree('_mouse_on_screen_2_mouse_on_screen_8ino-example.html','');});
/* @license-end */
</script>
<div id="doc-content">
<!-- window showing the filter options -->
<div id="MSearchSelectWindow"
     onmouseover="return searchBox.OnSearchSelectShow()"
     onmouseout="return searchBox.OnSearchSelectHide()"
     onkeydown="return searchBox.OnSearchSelectKey(event)">
</div>

<!-- iframe showing the search results (closed by default) -->
<div id="MSearchResultsWindow">
<iframe src="javascript:void(0)" frameborder="0" 
        name="MSearchResults" id="MSearchResults">
</iframe>
</div>

<div class="header">
  <div class="headertitle">
<div class="title">MouseOnScreen/MouseOnScreen.ino</div>  </div>
</div><!--header-->
<div class="contents">
<p>PS/2 mouse and mouse pointer on screen</p>
<div class="fragment"><div class="line"><span class="comment">/*</span></div><div class="line"><span class="comment">  Created by Fabrizio Di Vittorio (fdivitto2013@gmail.com) - www.fabgl.com</span></div><div class="line"><span class="comment">  Copyright (c) 2019 Fabrizio Di Vittorio.</span></div><div class="line"><span class="comment">  All rights reserved.</span></div><div class="line"><span class="comment"></span></div><div class="line"><span class="comment">  This file is part of FabGL Library.</span></div><div class="line"><span class="comment"></span></div><div class="line"><span class="comment">  FabGL is free software: you can redistribute it and/or modify</span></div><div class="line"><span class="comment">  it under the terms of the GNU General Public License as published by</span></div><div class="line"><span class="comment">  the Free Software Foundation, either version 3 of the License, or</span></div><div class="line"><span class="comment">  (at your option) any later version.</span></div><div class="line"><span class="comment"></span></div><div class="line"><span class="comment">  FabGL is distributed in the hope that it will be useful,</span></div><div class="line"><span class="comment">  but WITHOUT ANY WARRANTY; without even the implied warranty of</span></div><div class="line"><span class="comment">  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the</span></div><div class="line"><span class="comment">  GNU General Public License for more details.</span></div><div class="line"><span class="comment"></span></div><div class="line"><span class="comment">  You should have received a copy of the GNU General Public License</span></div><div class="line"><span class="comment">  along with FabGL.  If not, see &lt;http://www.gnu.org/licenses/&gt;.</span></div><div class="line"><span class="comment"> */</span></div><div class="line"></div><div class="line"></div><div class="line"><span class="preprocessor">#include &quot;<a class="code" href="fabgl_8h.html">fabgl.h</a>&quot;</span></div><div class="line"></div><div class="line"></div><div class="line"><span class="keywordtype">int</span> indicatorX = 300;</div><div class="line"><span class="keywordtype">int</span> indicatorY = 170;</div><div class="line"><span class="keywordtype">int</span> cursor     = 0;</div><div class="line"></div><div class="line"></div><div class="line"><span class="keywordtype">void</span> showCursorPos(MouseStatus <span class="keyword">const</span> &amp; status)</div><div class="line">{</div><div class="line">  Canvas.<a name="a0"></a><a class="code" href="classfabgl_1_1_canvas_class.html#a8dbddce234790b290cb4bd053dc0e701">setPenColor</a>(<a name="a1"></a><a class="code" href="group___enumerations.html#gga843f6f6094fb6666d0e726d7b0e06f3bab269b90a1d510bf6861b4584f7aa9720">Color::Blue</a>);</div><div class="line">  Canvas.<a name="a2"></a><a class="code" href="classfabgl_1_1_canvas_class.html#a9cec8cd2eb3f498b67ec7f20800131da">setBrushColor</a>(<a name="a3"></a><a class="code" href="group___enumerations.html#gga843f6f6094fb6666d0e726d7b0e06f3bacc98be810fb05ecb9fc7ea69a8e251c8">Color::Yellow</a>);</div><div class="line">  Canvas.<a name="a4"></a><a class="code" href="classfabgl_1_1_canvas_class.html#a45b0f278e677b6195ccea7bc377fe8c5">drawTextFmt</a>(indicatorX, indicatorY, <span class="stringliteral">&quot; %d %d &quot;</span>, status.X, status.Y);</div><div class="line">}</div><div class="line"></div><div class="line"></div><div class="line"><span class="keywordtype">void</span> setup()</div><div class="line">{</div><div class="line">  VGAController.<a name="a5"></a><a class="code" href="classfabgl_1_1_v_g_a_controller_class.html#acdc8b95372c01a76deeb4abe360d0295">begin</a>();</div><div class="line">  VGAController.<a name="a6"></a><a class="code" href="classfabgl_1_1_v_g_a_controller_class.html#ac190a844ead4bb68817c733fb0c9a5af">setResolution</a>(<a name="a7"></a><a class="code" href="fabglconf_8h.html#ae913dffdd13bd77b79d1a253e88bf22f">VGA_640x350_70HzAlt1</a>);</div><div class="line">  <span class="comment">//VGAController.setResolution(VGA_640x240_60Hz);    // select to have more free memory</span></div><div class="line"></div><div class="line">  <span class="comment">// Setup mouse</span></div><div class="line">  PS2Controller.<a name="a8"></a><a class="code" href="classfabgl_1_1_p_s2_controller_class.html#a7082e498e95fd5f5a4edfbe73923f397">begin</a>();</div><div class="line">  Mouse.<a name="a9"></a><a class="code" href="classfabgl_1_1_mouse_class.html#a27d4c98be698b46eabc8faea1d1cf48d">setupAbsolutePositioner</a>(Canvas.<a name="a10"></a><a class="code" href="classfabgl_1_1_canvas_class.html#aea413b9edfd1ba4d74289a7200bd2fe6">getWidth</a>(), Canvas.<a name="a11"></a><a class="code" href="classfabgl_1_1_canvas_class.html#abf1d0eae0cee9c7606b7a60c8f892ff5">getHeight</a>(), <span class="keyword">true</span>, <span class="keyword">true</span>, <span class="keyword">nullptr</span>);</div><div class="line">  VGAController.<a name="a12"></a><a class="code" href="classfabgl_1_1_v_g_a_controller_class.html#a192b049b972edc3eb8a817d641688f7d">setMouseCursor</a>((<a name="a13"></a><a class="code" href="group___enumerations.html#gae9affb623792aa869a11e81f3f10a372">CursorName</a>)cursor);</div><div class="line"></div><div class="line">  Canvas.<a class="code" href="classfabgl_1_1_canvas_class.html#a9cec8cd2eb3f498b67ec7f20800131da">setBrushColor</a>(<a class="code" href="group___enumerations.html#gga843f6f6094fb6666d0e726d7b0e06f3bab269b90a1d510bf6861b4584f7aa9720">Color::Blue</a>);</div><div class="line">  Canvas.<a name="a14"></a><a class="code" href="classfabgl_1_1_canvas_class.html#a37beec4d52526d2710d47d911a1cd8c2">clear</a>();</div><div class="line">  Canvas.<a name="a15"></a><a class="code" href="classfabgl_1_1_canvas_class.html#aec16bab7318419fde24db0b9a78d3281">selectFont</a>(Canvas.<a name="a16"></a><a class="code" href="classfabgl_1_1_canvas_class.html#aae47e5f03e69ed21dd07f4b73e43e4f0">getPresetFontInfo</a>(80, 25));</div><div class="line">  Canvas.<a name="a17"></a><a class="code" href="classfabgl_1_1_canvas_class.html#a4e8cfc8e0e279de0defc88d8e01443dc">setGlyphOptions</a>(GlyphOptions().FillBackground(<span class="keyword">true</span>));</div><div class="line"></div><div class="line">  showCursorPos(Mouse.<a name="a18"></a><a class="code" href="classfabgl_1_1_mouse_class.html#abd37dd534acd79983406a7327f040123">status</a>());</div><div class="line">}</div><div class="line"></div><div class="line"></div><div class="line"><span class="keywordtype">void</span> loop()</div><div class="line">{</div><div class="line">  MouseStatus status = Mouse.<a name="a19"></a><a class="code" href="classfabgl_1_1_mouse_class.html#af770cea972dce81506216a8556f086cd">getNextStatus</a>(-1); <span class="comment">// -1 = blocking operation</span></div><div class="line"></div><div class="line">  <span class="comment">// left button writes pixels</span></div><div class="line">  <span class="keywordflow">if</span> (status.buttons.left) {</div><div class="line">    Canvas.<a class="code" href="classfabgl_1_1_canvas_class.html#a8dbddce234790b290cb4bd053dc0e701">setPenColor</a>(<a name="a20"></a><a class="code" href="group___enumerations.html#gga843f6f6094fb6666d0e726d7b0e06f3ba810c94a5121684c7ef87d3ad25921ae2">Color::BrightRed</a>);</div><div class="line">    Canvas.<a name="a21"></a><a class="code" href="classfabgl_1_1_canvas_class.html#a3b0d0b0b79b816c9fd0d07a35dc0af99">setPixel</a>(status.X, status.Y);</div><div class="line">    Canvas.<a name="a22"></a><a class="code" href="classfabgl_1_1_canvas_class.html#a90e9335db302e55fa8ad402338398b76">moveTo</a>(status.X, status.Y);</div><div class="line">  }</div><div class="line"></div><div class="line">  <span class="comment">// right button change mouse shape</span></div><div class="line">  <span class="keywordflow">if</span> (status.buttons.right) {</div><div class="line">    cursor = ((<a class="code" href="group___enumerations.html#gae9affb623792aa869a11e81f3f10a372">CursorName</a>)cursor == <a name="a23"></a><a class="code" href="group___enumerations.html#ggae9affb623792aa869a11e81f3f10a372ab86f1dfdd29c0dc20ca59f8e122cce18">CursorName::CursorTextInput</a> ? 0 : cursor + 1);</div><div class="line">    VGAController.<a class="code" href="classfabgl_1_1_v_g_a_controller_class.html#a192b049b972edc3eb8a817d641688f7d">setMouseCursor</a>((<a class="code" href="group___enumerations.html#gae9affb623792aa869a11e81f3f10a372">CursorName</a>)cursor);</div><div class="line">  }</div><div class="line"></div><div class="line">  <span class="comment">// middle button clear screen</span></div><div class="line">  <span class="keywordflow">if</span> (status.buttons.middle) {</div><div class="line">    Canvas.<a class="code" href="classfabgl_1_1_canvas_class.html#a9cec8cd2eb3f498b67ec7f20800131da">setBrushColor</a>(<a class="code" href="group___enumerations.html#gga843f6f6094fb6666d0e726d7b0e06f3bab269b90a1d510bf6861b4584f7aa9720">Color::Blue</a>);</div><div class="line">    Canvas.<a class="code" href="classfabgl_1_1_canvas_class.html#a37beec4d52526d2710d47d911a1cd8c2">clear</a>();</div><div class="line">  }</div><div class="line"></div><div class="line">  <span class="comment">// mouse wheel moves cursor position indicator</span></div><div class="line">  <span class="keywordflow">if</span> (status.wheelDelta != 0) {</div><div class="line">    indicatorY = fabgl::tclamp(indicatorY + status.wheelDelta, 0, Canvas.<a class="code" href="classfabgl_1_1_canvas_class.html#abf1d0eae0cee9c7606b7a60c8f892ff5">getHeight</a>() - 16);</div><div class="line">    Mouse.<a class="code" href="classfabgl_1_1_mouse_class.html#abd37dd534acd79983406a7327f040123">status</a>().<a name="a24"></a><a class="code" href="structfabgl_1_1_mouse_status.html#a60e078de3e3bd4bbea7cb9c51774d1f6">wheelDelta</a> = 0;</div><div class="line">    Canvas.<a class="code" href="classfabgl_1_1_canvas_class.html#a9cec8cd2eb3f498b67ec7f20800131da">setBrushColor</a>(<a class="code" href="group___enumerations.html#gga843f6f6094fb6666d0e726d7b0e06f3bab269b90a1d510bf6861b4584f7aa9720">Color::Blue</a>);</div><div class="line">    Canvas.<a class="code" href="classfabgl_1_1_canvas_class.html#a37beec4d52526d2710d47d911a1cd8c2">clear</a>();</div><div class="line">  }</div><div class="line"></div><div class="line">  showCursorPos(status);</div><div class="line">}</div></div><!-- fragment --> </div><!-- contents -->
</div><!-- doc-content -->
<!-- start footer part -->
<div id="nav-path" class="navpath"><!-- id is needed for treeview function! -->
  <ul>
    <li class="footer">Generated by
    <a href="http://www.doxygen.org/index.html">
    <img class="footer" src="doxygen.png" alt="doxygen"/></a> 1.8.14 </li>
  </ul>
</div>
</body>
</html>
